﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Broadsides2d
{
    public class Tile
    {
        int x;
        int y;
        TileType type;

        public List<Object> contents;
        public static int SIZE = 8;

        public Tile(int x, int y)
        {
            this.type = TileType.water;
            this.x = x;
            this.y = y;
            contents = new List<Object>();
        }

        public Tile(int x, int y, TileType type) : this(x, y)
        {
            this.type = type;
        }

        public void Draw(SpriteBatch batch)
        {
            Vector2 v = Game1.recenter(this.x, this.y);

            int x = (((int)v.X + World.world.worldSizeInPixels) % World.world.worldSizeInPixels);
            int y = (((int)v.Y + World.world.worldSizeInPixels) % World.world.worldSizeInPixels);
            switch (type)
            {
                case TileType.land: batch.Draw(Texture2DManager.land, new Rectangle(x, y, SIZE, SIZE), Color.White);
                    break;
                case TileType.port: batch.Draw(Texture2DManager.port, new Rectangle(x, y, SIZE, SIZE), Color.White);
                    break;
                case TileType.water:
                    //batch.Draw(Texture2DManager.port, new Rectangle(x, y, SIZE, SIZE), Color.Red);
                    break;
            }
        }

        public int getX()
        {
            return this.x;
        }
        public int getY()
        {
            return this.y;
        }

        public enum TileType
        {
            water,
            land,
            port
        }

        public TileType getType(){
            return type;
        }
    }

    
}
